﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

using ZhimeiSoft.CharmManager.DOL;
using ZhimeiSoft.CharmManager.Server.BLL.Interface;
using ZhimeiSoft.CharmManager.Server.DAL.Interface;
using ZhimeiSoft.CharmManager.Server.Factory;

namespace ZhimeiSoft.CharmManager.Server.BLL
{
    public class CustomerPaymentBLL : ICustomerPaymentBLL
    {
        ICustomerPaymentDAL dal;
        ICustomerServiceItemBLL serivceItemBLL;

        public CustomerPaymentBLL()
        {
            dal = BaseDalFactory.CreateCustomerPaymentDal();
        }

        private ICustomerServiceItemBLL GetCustomerServiceItemBLL()
        {
            if (serivceItemBLL == null)
                serivceItemBLL = new CustomerServiceItemBLL();
            return serivceItemBLL;
        }

        #region ICustomerPaymentBLL 成员

        public DataSet GetCustomerPayment(string sFilter)
        {
            return dal.GetCustomerPayment(sFilter);
        }

        public void InsertCustomerPayment(DBEntityCustomerPayment entity)
        {
            dal.InsertCustomerPayment(entity);

            //更新会员账号余额
            GetCustomerServiceItemBLL().UpdateAccountMoney(entity.CustomerServiceItemID, entity.CMoney);
        }

        public void UpdateCustomerPayment(DBEntityCustomerPayment entity)
        {
            dal.UpdateCustomerPayment(entity);
        }

        public void DeleteCustomerPayment(int payment_id)
        {
            dal.DeleteCustomerPayment(payment_id);
        }

        #endregion
    }
}
